package cn.gson.work.model.service;

import cn.gson.work.model.mapper.TfilMapper;
import cn.gson.work.model.mapper.TfilesMapper;
import cn.gson.work.model.pojos.Tfil;
import cn.gson.work.model.pojos.Tfiles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
@Transactional
public class TfilService {
    @Autowired
    TfilMapper fm;
    @Autowired
    TfilesMapper fsm;
    public List<Tfil> findTfil(String fid, String fname, String fsecurity){
        return fm.findTfil(fid,fname,fsecurity);
    }
    public void addTfil(Tfil tfil){
        fm.addTfil(tfil);
    }
    public void editTfil(Tfil tfil){
        fm.editTfil(tfil);
    }
    public void delTfil(int id) {
        fm.delTfil(id);
    }
    public void delTs(int id){
        Tfil t= fm.findTfilByNo(id);
        System.out.println(t);
        fm.delTs(id);
        Tfiles ts=new Tfiles();
        ts.setFid(t.getFid());
        ts.setFname(t.getFname());
        ts.setFsecurity(t.getFsecurity());
        ts.setFborrower(t.getFborrower());
        ts.setFstate("未借出");
        ts.setDossier(t.getDossier());
        System.err.println(ts);
        fsm.addTfiles(ts);
    }
}
